#include <napi.h>
#include "./includes/window_api.h"

Napi::Array _getAllWindows(const Napi::CallbackInfo &info) {
    Napi::Env env = info.Env();
    std::vector<Window> windows = getAllWindows();
    auto array = Napi::Array::New(env, windows.size());
    for (size_t idx = 0; idx < windows.size(); ++idx) {
        Window window = windows[idx];
        array[idx] = window.convertNApiObject(env);
    }
    return array;
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
    exports.Set(Napi::String::New(env, "getAllWindows"), Napi::Function::New(env, _getAllWindows));
    return exports;
}

NODE_API_MODULE(scvzerng_tools, Init);